package cn.crm.system.service.impl;

import cn.crm.common.utils.SecurityUtils;
import cn.crm.system.domain.pojo.dto.ContactsDto;
import cn.crm.system.domain.pojo.dto.VisitingDto;
import cn.crm.system.domain.pojo.vo.ContactsVo;
import cn.crm.system.domain.pojo.vo.VisitingVo;
import cn.crm.system.mapper.ContactsMapper;
import cn.crm.system.mapper.VisitingMapper;
import cn.crm.system.service.IContactsService;
import cn.crm.system.service.IVisitingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 处理联系人的接口
 */

@Slf4j
@Service
public class VisitingServiceImpl implements IVisitingService {


    @Autowired
    private VisitingMapper visitingMapper;

    //通过公司id查询出联系人
    @Override
    public List<VisitingVo> selectVisitingsbyBusinessid(Long businessId) {
        log.debug("开始通过公司id查询出拜访记录");
        List<VisitingVo> visitingVos = visitingMapper.selectvisitingByBusinessId(businessId);
        return visitingVos;
    }
//新增拜访记录
    @Override
    public int insertVisiting(VisitingDto visitingDto) {
        log.debug("开始新增拜访记录");
        String createAccount = SecurityUtils.getUsername();
        visitingDto.setCreateBy(createAccount);
        int i = visitingMapper.insertVisiting(visitingDto);
        return i;
    }

    @Override
    public int delVisiting(Long[] id) {
        log.debug("开始删除拜访记录");
        int i = visitingMapper.delVisiting(id);
        return i;
    }

    @Override
    public int updateContacts(VisitingDto visitingDto) {
        log.debug("开始修拜访记录");
        int i = visitingMapper.updateVisiting(visitingDto);
        return i;
    }

    @Override
    public List<VisitingVo> selectVisitings(VisitingDto visitingDto) {
        log.debug("开始查询拜访记录");
        List<VisitingVo> visitingVos = visitingMapper.selectVisitings(visitingDto);
        return visitingVos;
    }

}
